<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>水平居中</title>
    <style>
        /* 字体居中，左右居中 。字体上下居中，height=ling-height */
        .outer{
            position: relative;
            width: 200px;
            height: 200px;
            background-color: skyblue;
            /* text-align: center;  */
            display: flex;
            justify-content: center;
            align-items: center;
            
        }
        .inner{
            display: block;
            width: 100px;
            height: 100px;

            /* position: absolute;
            top: 50%;
            right: 50%; */
            /* margin-top: -50px; */
            /* transform: translateY(-50%);
            margin-right: -50px; */
            background-color: pink;
           
            /* margin: 0 auto;
            background-color: pink; */
        }
    </style>
</head>
<body>
    <div class="outer">
        <span class="inner">行级元素</span>
    </div>
</body>
</html>